package com.juitar.chordfinder;

import java.awt.Component;

import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

import com.juitar.base.Fingering;

/**
 * @author SKopylov
 */
public class FingeringRenderer implements TableCellRenderer {

	/**
	 * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, java.lang.Object, boolean, boolean, int, int)
	 */
	public Component getTableCellRendererComponent(
		JTable table,
		Object value,
		boolean isSelected,
		boolean hasFocus,
		int row,
		int column) {

		if (value == null) {
			return emptyPanel;
		}
		if (isSelected) {
			selectedBean.setFingering((Fingering) value);
			selectedBean.setBorder();
			return selectedBean;
		} else {
			bean.setFingering((Fingering) value);
			return bean;
		}
	}

	static JPanel emptyPanel = new JPanel();
//	FingeringBean2D bean = new FingeringBean2D();
//	FingeringBean2D selectedBean = new FingeringBean2D();
	FingeringBean bean = new FingeringBean();
	FingeringBean selectedBean = new FingeringBean();
}
